{% extends "forum/forumbase.html" %}

{% comment %}
#    Copyright 2012 New Mexico EPSCoR
#
#    This file is part of Teacher's P.E.T.
#
#    Teacher's P.E.T. is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Teacher's P.E.T. is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Teacher's P.E.T..  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}

{% load files %}

{% block title %} {{message.subject}} | {{block.super}}{% endblock title %}

{% block css %}
    {{block.super}}
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/forum.css" >
{% endblock css %}

{% block content %}
<div class="forum-message">
	<hr>
	<table class="forum-message-header">
		<tr>
			<td class="forum-message-create-new">
				{% if not ban or ban.message_ban < ban.BAN_NEW_MESSAGES %}
					<a class="forum-message-button" href="{% course_url forum_send_message %}">Compose</a>
				{% endif %}
			</td>
		</tr>
	</table>
	<table class="forum-message-table" border=0>
		<tr>
			<td class="forum-message-index">
				<table class="forum-message-index-table" border=0>
					<tr>
						<td>
							{% if user.unread_messages.count > 0 %}
								<a href="{% course_url forum_view_folder folder='inbox' %}"><b>Inbox&nbsp({{user.unread_messages|length}})</b></a>
							{% else %}
								<a href="{% course_url forum_view_folder folder='inbox' %}">Inbox</a>
							{% endif %}
						</td>
					</tr>
					<tr>
						<td>
							<a href="{% course_url forum_view_folder folder='drafts' %}">Drafts{% if user.draft_messages|length > 0 %}&nbsp({{user.draft_messages|length}}){% endif %}</a>
						</td>
					</tr>
					<tr><td><a href="{% course_url forum_view_folder folder='sent' %}">Sent</a></td></tr>
					<tr><td><a href="{% course_url forum_view_folder folder='trash' %}">Trash</a></td></tr>
					{% if request.user.block_list.all|length > 0 %}<tr><td><hr><a href="{% course_url forum_view_blocklist %}">Block&nbsp;List</a></td></tr>{% endif %}
				</table>
			</td>
			<td class="forum-message-message">
				<table class="forum-message-message-table" cellpadding=0 cellspacing=0 border=0>
					<tr>
						<td colspan="100%" class="forum-message-subject">
							{{message.subject}}
							<span class="forum-message-options">
								{% if message.can_be_unread %}
									<a href="{% course_url forum_unread_message message_id=message.id %}" title="Mark this message as unread"><img src="{{STATIC_URL}}images/unread.png" height="20"></a>
								{% endif %}
								{% if message.can_be_deleted %}
									<a href="{% course_url forum_delete_message message_id=message.id %}" title="Delete this message"><img src="{{STATIC_URL}}images/delete.png" height="20"></a>
								{% endif %}
								{% if message.can_be_undeleted %}
									<a href="{% course_url forum_undelete_message message_id=message.id %}" title="Restore this message"><img src="{{STATIC_URL}}images/undelete.png" height="20"></a>
								{% endif %}
							</span>
						</td>
					</tr>
					{% get_file_list for message as Files %}
					<tr>
						<td class="forum-message-sender-avatar">
						{% with User=users|getitem:message.sender %}
							<img src="{% if User.avatar %}{{User.avatar}}{% else %}{{STATIC_URL}}images/BlankAvatar.png{% endif %}" height="25">
						{% endwith %}
						</td>
						<td class="forum-message-sender"><span class="forum-message-sender-info">{{message.sender_name}}</span><br><span class="forum-message-recipient">to&nbsp;{{message.recipient_name}}</span></td>
						<td class="forum-message-date">{% if Files %}<span class="forum-messages-date-attachment"><img src="{{STATIC_URL}}images/attachment.png" height="15"></span>{% endif %}{{message.send_date|date:"g:i a"|spacify}},&nbsp;{{message.send_date|date:"M d, Y"|spacify}}</td>
					</tr>
					<tr>
						<td></td>
						<td class="forum-message-body" colspan="100%">
							{% render message.message %}
							{% if Files %}
							<span class="forum-send-message-files">
								<hr>
								<span class="forum-messages-message-attachment"><img src="{{STATIC_URL}}images/attachment.png" height="15"></span>
								Attachments:
								<ul>
									{% for file in Files %}
										<li>
											<a href="{% course_url forum_download_message_attachment message_id=message.id filename=file.filename %}" target="_blank">
												<img src="{{STATIC_URL}}images/files/{{file.icon}}" height="25"> {{file.title}}{% if file.extension %}.{{file.extension}}{% endif %}
											</a>{% if file.description %} - {{file.description}}{% endif %}
										</li><br>
									{% endfor %}
								</ul>
							</span>
							{% endif %}
						</td>
					</tr>
					<tr>
						<td class="forum-message-reply-buttons-empty"></td>
						<td colspan="100%" class="forum-message-reply-buttons">
							{% if not ban or ban.message_ban < ban.BAN_REPLIES %}
								<a class="forum-message-button" href="{% course_url forum_reply_to_message reply_to=message.id %}">Reply</a>
								<a class="forum-message-button" href="{% course_url forum_forward_message reply_to=message.id %}">Forward</a>
							{% endif %}
							<span class="forum-message-report-button">
								{% if message.can_be_flagged %}
									{% if message.is_marked_for_moderator %}
										<img src="{{STATIC_URL}}images/thumbs_down_done.png" height="20" title="This message has been marked for review for inappropriate content"></a>
									{% else %}
										<a href="{% course_url forum_report_message message_id=message.id %}" title="Report this message for inappropriate content"><img src="{{STATIC_URL}}images/thumbs_down.png" height="20"></a>
									{% endif %}
								{% endif %}
								{% if message.can_be_blocked %}
									<a href="{% course_url forum_block_message_sender message_id=message.id %}" title="Block this user from messaging you (and vice-versa)"><img src="{{STATIC_URL}}images/block.png" height="20"></a>
								{% endif %}
							</span>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	
</div>
{% endblock content %}